const express = require('express');
const router = express.Router();

router.get('/', (req, res) => {
    const content = [];
    for(let i = 0; i < 40; i++)
        content.push({
            id: `2019${i}`,
            dealerCode: `dealerCode${i}`,
            dealerName: `总代名称${i}`,
            code: `code00${i}`,
            salePackingListCode: `salePackingListCode${i}`,
            currency: 1,
            totalAmount: 4654613,
            status: 1,
            createTime: '2020-03-02T07:49:31.607Z',
            rowVersion: 'rowVersion',
            options: [
                'update',
                'abandon',
                'confirm',
            ]
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 40,
        }
    });
});
router.get('/:id', async(req, res, next) => {
    res.json({
        message: '',
        payload: {
            id: '001',
            code: 'code001',
            dealerId: '001',
            dealerCode: 'dealerCode001',
            dealerName: 'dealerName001',
            brandId: '001',
            brandName: 'brandName',
            salePackingListCode: 'salePackingListCode',
            salePackingListId: 'salePackingListId11',
            currency: 1,
            totalAmount: 21312312,
            status: 1,
            remark: 'remark',
            creatorName: 'creatorName',
            createTime: '2020-03-02T08:40:53.602Z',
            modifierName: 'modifierName',
            modifyTime: '2020-03-02T08:40:53.602Z',
            abandonerName: 'abandonerName',
            abandonTime: '2020-03-02T08:40:53.602Z',
            confirmorName: 'confirmorName',
            confirmTime: '2020-03-02T08:40:53.602Z',
            attachments: [
                {
                    fileId: '001',
                    fileName: 'fileName001'
                }
            ],
            details: [
                {
                    id: '001',
                    code: 'code',
                    dealerCode: 'dealerCode001',
                    dealerName: 'dealerName001',
                    saleConfirmationrCode: 'saleConfirmationrCode1',
                    batchNumber: 'batchNumber001',
                    status: 1,
                    packingType: 1,
                    container: 'container',
                    length: 12.2,
                    width: 2.21,
                    height: 3.21,
                    volume: 23.31,
                    netWeight: 21.21,
                    grossWeight: 12.21,
                    currency: 1,
                    createTime: '2020-04-21T09:10:24.713Z'
                }
            ],
            rowVersion: 'string',
            options: ['update', 'abandon', 'confirm'],
        }
    });
});

router.post('/', async(req, res, next) => {
    res.json({
        message: '新增成功'
    });
});

router.put('/:id', async(req, res, next) => {
    res.json({
        message: '编辑成功'
    });
});

router.put('/:id/confirm', (req, res) => {
    res.json(
        {
            message: '确认成功'
        }
    );
});

router.put('/:id/abandon', (req, res) => {
    res.json(
        {
            message: '作废'
        }
    );
});

router.get('/export', async(req, res, next) => {
    res.json({
        message: '导出成功',
        payload: 'Mock导出'
    });
});

module.exports = router;
